package com.springapp.controller;

/**
 * Created by nicol_000 on 14/03/14.
 */


import com.springapp.service.impl.CommandeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;


@Controller
@RequestMapping(value="/lstCommandesNonAffectees")
public class ControlAllCmdNonDesigneesPrepa {
    @Autowired
    private CommandeService listeCommandeByStatusByUsersService;


    @RequestMapping(value="/all", method = RequestMethod.GET)
    public ModelAndView displayList() {
        ModelAndView model = new ModelAndView("listeCommandeNonAffectees");
        model.addObject("lstCmd", listeCommandeByStatusByUsersService.getLstCmdNotPrepared());
        return model;
    }

    @RequestMapping(value="/affecte" ,  method = RequestMethod.POST)
    public ModelAndView updateList(@RequestParam("sRefCmd") String sRef) {
        ModelAndView model = new ModelAndView("listeCommandeNonAffectees");


        model.addObject("UpdateOK", listeCommandeByStatusByUsersService.update(sRef));
        model.addObject("sRefCommandeUpdateOK", sRef);
        model.addObject("lstCmd", listeCommandeByStatusByUsersService.getLstCmdNotPrepared());
        return model;
    }
}
